package com.shop.cloud.service.hongfu.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.shop.cloud.common.mybatis.BaseService;
import com.shop.cloud.common.mybatis.MybatisDao;
import com.shop.cloud.dao.hongfu.WithdrawHistoryDao;
import com.shop.cloud.domain.hongfu.WithdrawHistory;
import com.shop.cloud.service.hongfu.IWithdrawHistoryService;
import com.shop.cloud.util.Page;

/**
 * withdraw_history
 */
@Service("withdrawHistoryService")
public class WithdrawHistoryService extends BaseService<WithdrawHistory> implements IWithdrawHistoryService{
    
    @Autowired
	private WithdrawHistoryDao withdrawHistoryDao;

	@Override
	public MybatisDao<WithdrawHistory> getEntityDao() {
		return withdrawHistoryDao;
	}
	
	public Page<WithdrawHistory> allPage(WithdrawHistory withdrawHistory) {
		withdrawHistory.setPageSize((withdrawHistory.getPageSize_()==null?20:withdrawHistory.getPageSize_()));
		long count = withdrawHistoryDao.getWithdrawHistoryCount(withdrawHistory);
		Page<WithdrawHistory> page = new Page<WithdrawHistory>(withdrawHistory.getPageIndex_(), withdrawHistory.getPageSize_());
		List<WithdrawHistory> data =withdrawHistoryDao.getWithdrawHistoryList(withdrawHistory);
		if(data!=null&&data.size()>0){
			for (WithdrawHistory ww : data) {
				ww.setDescrip(ww.getDescription());
			}
		}
		page.setData(data);
		page.setTotalCount(count);
		return page;
	}
	
	public Page<WithdrawHistory> PageList(WithdrawHistory withdrawHistory) {
		withdrawHistory.setPageSize((withdrawHistory.getPageSize_()==null?20:withdrawHistory.getPageSize_()));
		long count = withdrawHistoryDao.searchWithdrawHistoryCount(withdrawHistory);
		
		Page<WithdrawHistory> page = new Page<WithdrawHistory>(withdrawHistory.getPageIndex_(), withdrawHistory.getPageSize_());
		List<WithdrawHistory> data =withdrawHistoryDao.searchWithdrawHistoryList(withdrawHistory);
		page.setData(data);
		page.setTotalCount(count);
		return page;
	}
    
}